import grpc
import hello_pb2
import hello_pb2_grpc
import json
def run():
 # 连接 rpc 服务器
 channel = grpc.insecure_channel('localhost:50052')
 # 调用 rpc 服务
 stub = hello_pb2_grpc.GreeterStub(channel)
 response = stub.SayHello(hello_pb2.HelloRequest(name='czl'))
 print("Greeter client received: " + response.message)
 response = stub.SayHelloAgain(hello_pb2.HelloRequest(name='nsdnfkjda'))
 print("Greeter client received: " + response.message)
 stub1 = hello_pb2_grpc.GreeteraStub(channel)
 response1 = stub1.SayStudent(hello_pb2.Studentid(id='1'))
 print(json.loads(response1.msg))
if __name__ == '__main__':
 run()